<?php
/**
 *
 * 版权所有：安德玛(underArmour)
 * 作    者：1554324405@qq.com
 * 日    期：2020-05-20
 * 版    本：1.0.0
 * 功能说明：推广赚钱控制器。
 *
 **/
namespace Api\Controller;

class PromoteController extends ComController
{
    /**
     * 推广赚钱页面接口
     */
    public function index()
    {
		$user_info = M('user')->where('id='.$this->user['id'])->field('tuiguang_num')->find();
		$tuiguang_num = $user_info['tuiguang_num'] + 1;
		$data['tuiguang_num'] = $tuiguang_num;
		$res1 = M('user')->data($data)->where('id='.$this->user['id'])->save();
        //生成推广二维码
        $qrcode_path = './Public/attached/qrcode/code'.'_'.$this->user['id'].'.png';
        $content = C('SITE_URL').'/qrcoderegister?refer='.$this->user['int_code'];
        if(!is_file($qrcode_path)){
            $qrcode_path = './Public/attached/qrcode/code'.'_'.$this->user['id'].'.png';
            $matrixPointSize = 10;
            $matrixMarginSize = 1;
            $errorCorrectionLevel = 'M';
            makecode_no_pic($content,$qrcode_path,$matrixPointSize,$matrixMarginSize,$errorCorrectionLevel);
        }
        $this->res['data']['qrcode'] = C('URL').'/Public/attached/qrcode/code'.'_'.$this->user['id'].'.png';
        $this->res['data']['int_code'] = $this->user['int_code'];
        $this->res['data']['url'] = $content;
        $this->response($this->res,'json');
    }
}